﻿using SanJ.FreeCare.Patients;
using SanJ.FreeCare.TypeFramework;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Domain.Values;
using Volo.Abp.MultiTenancy;

namespace SanJ.FreeCare.Encounters
{
    public class Encounter : AuditedAggregateRoot<Guid>, IMultiTenant, ISoftDelete
    {
        /// <summary>
        /// Identifier(s) by which this encounter is known
        /// </summary>
        public List<Identifier> Identifier { get; private set; }

        /// <summary>
        /// 一般存储关联HIS或第三方的ID，住院号、挂号流水号等业务号
        /// </summary>
        public string ThirdId { get; private set; }

        /// <summary>
        /// planned | arrived | triaged | in-progress | onleave | finished | cancelled +
        /// </summary>
        public string StatusCode { get; private set; }
        /// <summary>
        /// inpatient | outpatient | ambulatory | emergency +
        /// EncounterClass 表示就诊的分类 门诊 急救 住院等等
        /// </summary>
        public string[] ClassCode { get; private set; }

        /// <summary>
        /// Specific type of encounter
        /// </summary>
        public string[] TypeCode { get; private set; }

        /// <summary>
        ///   Specific type of service 
        ///   http://build.fhir.org/valueset-service-type.html
        ///   可以简单理解为学科，这次看诊医疗机构提供了什么类型的服务
        /// </summary>
        public string ServiceType { get; private set; }

        /// <summary>
        ///   Indicates the urgency of the encounter 
        ///   优先级护理等级
        /// </summary>
        public string Priority { get; private set; }

        /// <summary>
        /// The patient present at the encounter
        /// </summary>
        public Patient Patient { get; private set; }

        /// <summary>
        /// The current status of the subject in relation to the Encounter
        /// arrived | triaged | on-leave | departed 
        /// </summary>
        public string PatientStatus { get; private set; }

        /// <summary>
        /// 实际开始时间
        /// </summary>
        public DateTime? ActualStartPeriod { get; private set; }

        /// <summary>
        /// 实际结束时间
        /// </summary>
        public DateTime? ActualEndPeriod { get; private set; }

        /// <summary>
        /// 计划开始时间
        /// </summary>
        public DateTime? PlannedStartDate { get; private set; }

        /// <summary>
        /// 计划结束时间
        /// </summary>
        public DateTime? PlannedEndDate { get; private set; }

        /// <summary>
        /// 饮食
        /// </summary>
        public string DietPreference { get; private set; }

        /// <summary>
        /// 特殊安排
        /// </summary>
        public string SpecialArrangement { get; private set; }

        /// <summary>
        /// 特殊待遇 可编码概念特别礼遇（VIP、董事会成员）
        /// </summary>
        public string[] SpecialCourtesyCode { get; private set; }

        /// <summary>
        /// 来源类型  --对照 organization、location、code
        /// </summary>
        public string OriginType { get; private set; }

        /// <summary>
        /// 来源类型ID  --Guid
        /// </summary>
        public string OriginId { get; private set; }

        /// <summary>
        /// 去向类型
        /// </summary>
        public string DestinationType { get; private set; }

        /// <summary>
        /// 去向ID
        /// </summary>
        public string DestinationId { get; private set; }

        public bool IsDeleted { get; set; }

        public Guid? TenantId { get; set; }

        public Encounter(){}

        public Encounter(List<Identifier> identifier, string thirdId, string statusCode, string[] classCode, string[] typeCode, string serviceType, string priority, Patient patient, string patientStatus, DateTime? actualStartPeriod, DateTime? actualEndPeriod, DateTime? plannedStartDate, DateTime? plannedEndDate, string dietPreference, string specialArrangement, string[] specialCourtesyCode, string originType, string originId, string destinationType, string destinationId)
        {
            this.Identifier = identifier;
            this.ThirdId = thirdId;
            this.StatusCode = statusCode;
            this.ClassCode = classCode;
            this.TypeCode = typeCode;
            this.ServiceType = serviceType;
            this.Priority = priority;
            this.Patient = patient;
            this.PatientStatus = patientStatus;
            this.ActualStartPeriod = actualStartPeriod;
            this.ActualEndPeriod = actualEndPeriod;
            this.PlannedStartDate = plannedStartDate;
            this.PlannedEndDate = plannedEndDate;
            this.DietPreference = dietPreference;
            this.SpecialArrangement = specialArrangement;
            this.SpecialCourtesyCode = specialCourtesyCode;
            this.OriginType = originType;
            this.OriginId = originId;
            this.DestinationType = destinationType;
            this.DestinationId = destinationId;
        }
    }

}
